import Cookies from 'js-cookie'
const TokenKey = 'Admin-Token'

export function getToken() {
  return Cookies.get(TokenKey)
}

export function setToken(token) {
  return Cookies.set(TokenKey, token)
}

export function removeToken() {
  return Cookies.remove(TokenKey)
}

export function setCookie(name, value, iDay) {
  var oDate = new Date();
  oDate.setDate(oDate.getDate() + iDay);
  document.cookie = name + '=' + value + ';expires=' + oDate;
};
export function setTop() {
  const EditTinId = document.querySelector('#EditTinId')
  const elements = document.querySelectorAll('.tox.tox-tinymce.tox-tinymce-inline');
  if (elements.length >= 1&&EditTinId) {
    elements.forEach(div => {
      if (div?.style.display === 'flex') {
        div.style.top = 0 + 'px';
        div.style.width = EditTinId.clientWidth + 'px';
        div.style.zIndex = '999999'
      }
    })
  }
}
/** 随机 uuid */

import { nanoid } from 'nanoid'

export const nanoIds = (size = 7) => {
    return nanoid(size)
}